#define _CRT_SECURE_NO_WARNINGS

#include"RBTree.hpp"
namespace mymap
{
	template<class K, class V>
	class map
	{
		struct KeyOfV
		{
			const K& operator()(const pair<const K, V>& obj)
			{
				return obj.first;
			}
		};
	public:
		typedef typename RBTree<K, pair<const K, V>, KeyOfV>::Iterator  iterator;
	    typedef typename RBTree<K, pair<const K, V>, KeyOfV>::ConstIterator const_iterator;


		iterator begin()
		{
			return tree.Begin();
		}
		iterator end()
		{
			return tree.End();
		}
		const_iterator begin()const
		{
			return tree.Begin();
		}
		const_iterator end()const
		{
			return tree.End();
		}
		pair<iterator,bool> insert(const pair<K, V>& data)
		{
			return tree.Insert(data);
		}
		bool empty()const
		{
			return tree.Empty();
		}
		size_t size()const
		{
			return tree.Size();
		}
		void swap(map&obj)
		{
			tree.Swap(obj.tree);
		}
		void clear()
		{
			tree.Clear();
		}
		iterator find(const K& key)
		{
			return tree.Find(key);
		}
		const_iterator find(const K& key) const
		{
			return tree.Find(key);
		}
		V& operator[] (const K& key)
		{
			pair<iterator, bool> tmp = insert(make_pair(key,V()));
			iterator it = tmp.first;
			return it->second;
		}
	private:
		RBTree<K, pair<const K, V>, KeyOfV> tree;
	};
}